#include <QtOpenGL>
#include "cubo.h"
#include <GL/glu.h>

//bool MostraShader = false;

int r,g,b;
Cubo::Cubo(const QVector3D& center, QObject *parent):
    Object3D(center, parent)
{

    QDir d("../dojoQT/");
          program.addShaderFromSourceFile(QGLShader::Vertex,
                                          d.absolutePath()+"/bola.vert");
          program.addShaderFromSourceFile(QGLShader::Fragment,
                                          d.absolutePath()+"/bola.frag");
          program.link();

    // connect(mainWindow, SIGNAL(ShaderSelect(bool)), this, SLOT(ShaderLigado(bool)));
}

void Cubo::drawGeometry(void)
{
    if(mostraShader) {program.bind();}
  //   glScalef(0.5, 0.5, 0.5);
    glScalef(2,2,2);
  //  glColor3f(r,g,b);
    glBegin(GL_QUADS);

  //  glColor3f(1.0,0.0,0.0);
    glNormal3f(0.0,0.0,-1.0);
    glVertex3i(0,0,0);
    glVertex3i(0,1,0);
    glVertex3i(1,1,0);
    glVertex3i(1,0,0);

   // glColor3f(0.0,1.0,0.0);
    glNormal3f(0.0,0.0,1.0);
    glVertex3i(0,0,1);
    glVertex3i(1,0,1);
    glVertex3i(1,1,1);
    glVertex3i(0,1,1);

   // glColor3f(0.0,0.0,1.0);
    glNormal3f(1.0,0.0,0.0);
    glVertex3i(1,0,0);
    glVertex3i(1,1,0);
    glVertex3i(1,1,1);
    glVertex3i(1,0,1);

//    glColor3f(0.0,1.0,1.0);
    glNormal3f(-1.0,0.0,0.0);
    glVertex3i(0,0,0);
    glVertex3i(0,0,1);
    glVertex3i(0,1,1);
    glVertex3i(0,1,0);

  //  glColor3f(1.0,1.0,1.0);
    glNormal3f(0.0,1.0,0.0);
    glVertex3i(0,1,0);
    glVertex3i(0,1,1);
    glVertex3i(1,1,1);
    glVertex3i(1,1,0);

 //   glColor3f(1.0,1.0,0.0);
    glNormal3f(0.0,-1.0,0.0);
    glVertex3i(0,0,0);
    glVertex3i(1,0,0);
    glVertex3i(1,0,1);
    glVertex3i(0,0,1);

    glEnd();

    if(mostraShader) {  program.release(); }


}
